﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BestBuy.DAL;
namespace BestBuy
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Flag"].ToString().Equals(""))
            {
                lbanimated.CssClass = "animated_div";
                Session["Flag"] = "1";
            }
            else { lbanimated.CssClass = "noanimated_div"; }

            if (Session["TenDN"].ToString().Equals(""))
            {
                pnLoginView.Visible = true;
                pnLoginedView.Visible = false;
            }
            else
            {
                lbWelcome.Text = "Wellcome";
                lbWelcome.Text = lbWelcome.Text+ "! " + Session["TenDN"].ToString();
                pnLoginedView.Visible = true;
                pnLoginView.Visible = false;
                if (CMessage.countMessage(int.Parse(Session["IDDN"].ToString())) != 0)
                {
                    notiMess.Visible = true;
                    notiMess.Text = "(" +CMessage.countMessage(int.Parse(Session["IDDN"].ToString())).ToString() + ")";
                }
                if (Session["LoaiTK"].ToString().Equals("1")) //Buyer
                {
                    //xu ly hien trang gi trong MyPage
                    lbMyPage.Text = "My Buyer";
                    hlMyPage.NavigateUrl = "~/PageUser/MbBuying.aspx";
                    hlInfomation.NavigateUrl = "~/PageUser/EditProfile.aspx";
                }
                else if (Session["LoaiTK"].ToString().Equals("2")) //Suplier
                {
                    //xu ly hien trang gi trong MyPage
                    lbMyPage.Text = "My Seller";
                    hlMyPage.NavigateUrl = "~/PageUser/MbSellling.aspx";
                    hlInfomation.NavigateUrl = "~/PageUser/EditProfile.aspx";
                }
                else if (Session["LoaiTK"].ToString().Equals("3")) //NV QL
                {
                    //xu ly hien trang gi trong MyPage
                    lbMyPage.Text = "Check Product";
                    hlMyPage.NavigateUrl = "~/PageAdmin/PageProductManager.aspx";
                    hlInfomation.NavigateUrl = "~/PageUser/EditProfile.aspx";
                }
                else  // 4 - NV NS
                {
                    //xu ly hien trang gi trong MyPage
                    lbMyPage.Text = "Manage Users";
                    hlMyPage.NavigateUrl = "~/PageAdmin/PageUsersManager.aspx";
                    hlInfomation.NavigateUrl = "~/PageAdmin/PageEditProfile.aspx";
                }
            }
            
        }
        
    }
}
